package com.kuangstudy.common.demo6;

/**
 * ClassName: Demo6
 * date: 2021/07/14 17:11:52
 *验证StringBuilder效率高于String
 * @author zlk
 */
public class Demo6 {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < 99999; i++) {
            str.append(i);
        }
        long end = System.currentTimeMillis();
        System.out.println("用时" + (end - start) + "ms");//String用时26611ms StringBuilder 用时15ms
    }
}
